import React, { Component } from 'react-native';
//组件
import Topbar from '../components/bwmain/topbar';
import DayRecordList from '../components/bwmain/dayRecordList'
//redux
import {bindActionCreators} from 'redux';
import * as mainScreenActions from '../actions/mainScreenActions';
import { connect } from 'react-redux';
const {
  StyleSheet,
  View,
  Text,
  ViewPagerAndroid,
  TouchableOpacity
} = React;



class bwmain extends Component {
	constructor(props) {
	    super(props);
	    //LayoutAnimation.configureNext(LayoutAnimation.Presets.spring);
	    this.state={
	    	currentTab:0
	    }
	 }
	render() {
	    return (
	      <View style={styles.contain}>
	      	<View style={styles.topbar}><Topbar reduxBwmain={this.props.mapstate.bwmain} navigator={this.props.navigator}></Topbar></View>
	     	<View style={styles.dayRecordList}><DayRecordList></DayRecordList></View>
	      </View>
	    );
	}
}

var styles = StyleSheet.create({
	contain:{
		flex:1
	},
	topbar:{
		flex:1,
		//backgroundColor:'red'
	},
	dayRecordList:{
		flex:10
	}
});

//将全局state绑定到组件的props中
function mapStateToProps(state) {
  return { 
    //state字段key
    mapstate: state.mainScreenRedux,//在上面的组件实例化时存入 
  }
}

//绑定一个方法到props中
function mapDispatchToProps(dispatch) {
  return { 
    mapactions: bindActionCreators(mainScreenActions, dispatch) 
  }
}

//将全局的state绑定到组件中
export default connect(mapStateToProps,mapDispatchToProps)(bwmain);
